// 设置 console 环境下的前景色和背景色

#ifndef TOOLBARJOYSTICK_H
#define TOOLBARJOYSTICK_H

#include <Windows.h>
using namespace std;

enum ConsoleTextColor{CTC_RED = FOREGROUND_INTENSITY | FOREGROUND_RED,
                  CTC_GREEN = FOREGROUND_INTENSITY | FOREGROUND_GREEN,
                  CTC_BLUE = FOREGROUND_INTENSITY | FOREGROUND_BLUE,
                  CTC_YELLOW = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN,
                  CTC_PURPLE = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE,
                  CTC_CYAN = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE,
                  CTC_WHITE = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
                  CTC_BLACK = 0};

enum ConsoleBackGroundColor{CBC_RED = BACKGROUND_INTENSITY | BACKGROUND_RED,
                  CBC_GREEN = BACKGROUND_INTENSITY | BACKGROUND_GREEN,
                  CBC_BLUE = BACKGROUND_INTENSITY | BACKGROUND_BLUE,
                  CBC_YELLOW = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN,
                  CBC_PURPLE = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE,
                  CBC_CYAN = BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE,
                  CBC_WHITE = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE,
                  CBC_BLACK = 0};

/**
 * @brief setConsoleColor 设置命令行输出的颜色
 * @param textColor 前景色
 * @param backgroundColor 背景色
 */
inline void setConsoleColor(ConsoleTextColor textColor = CTC_WHITE, ConsoleBackGroundColor backgroundColor = CBC_BLACK)
{
    //STD_ERROR_HANDLE;
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(handle, textColor | backgroundColor);
}			  
#endif // TOOLBARJOYSTICK_H